package com.design.strategy.shallow;

import java.util.ArrayList;
import java.util.List;

public class Client {

    public static void main(String[] args) {
        // 创建对象
        ConcretePrototype prototype = new ConcretePrototype();
        prototype.setAge(19);
        prototype.setName("lisa");
        // List 属于引用类型
        List<String> hobbies = new ArrayList<>();
        hobbies.add("书法");
        hobbies.add("健身");
        prototype.setHobbies(hobbies);


        //拷贝对象
        ConcretePrototype cloneType = prototype.clone();
        cloneType.getHobbies().add("技术控");
        System.out.println("克隆对象:" + cloneType);
        System.out.println("原型对象:" + prototype);
        System.out.println(cloneType == prototype);

        System.out.println("克隆对象爱好:" + cloneType.getHobbies());
        System.out.println("原型对象爱好:" + prototype.getHobbies());
        System.out.println(cloneType.getHobbies() == prototype.getHobbies());

    }
}
